package model;

import context.MachineContext;
import state.IdleState;
import state.WorkingState;
import strategy.PathPlanningStrategy;

public class Sower implements AgriculturalMachine {
    private PathPlanningStrategy strategy;
    private MachineContext context = new MachineContext();
    private String status = "空闲";

    public Sower() {
        context.setState(new IdleState());
    }

    @Override
    public void start() {
        status = "工作中";
        System.out.println("播种机启动");
        context.setState(new WorkingState());
    }

    @Override
    public void stop() {
        status = "空闲";
        System.out.println("播种机停止");
        context.setState(new IdleState());
    }

    @Override
    public void setPathPlanningStrategy(PathPlanningStrategy strategy) {
        this.strategy = strategy;
    }

    @Override
    public String planPath() {
        return strategy.planPath();
    }

    @Override
    public String getStatus() {
        return status;
    }

    @Override
    public String getLocation() {
        // 这里可以根据实际情况返回播种机的位置信息
        return "播种机当前位置信息";
    }

    @Override
    public double getFuel() {
        // 这里可以根据实际情况返回播种机的油量
        return 40.0;
    }

    public void checkStatus() {
        context.request();
    }
}